package cn.sciento.farm.devicemanager.gateway.model.uplink;

import cn.sciento.farm.devicemanager.common.util.NumberUtil;
import com.alibaba.fastjson.annotation.JSONField;

public class FertilizerUplinkPacket {

    private Integer id;

    private Integer channel;

    private Integer pump;

    private Integer fertilizeValve;

    private Integer status;

    private Integer stirringMotor;

    private Float fertilizeRatio;

    private Integer fault;

    @JSONField(name = "EntryEC")
    private Float entryEC;

    @JSONField(name = "EntryPH")
    private Float entryPH;

    @JSONField(name = "ExitEC")
    private Float exitEC;

    @JSONField(name = "ExitPH")
    private Float exitPH;

    private Float instantFlow;

    private Double totalFlow;

    private Float pressure;

    public boolean isMainPump(){
        if(this.pump == null){
            return false;
        }
        return true;
    }

    public boolean isValve(){
        if(this.fertilizeValve == null){
            return false;
        }
        return true;

    }

    public boolean isMotor(){
        if(this.stirringMotor == null){
            return true;
        }
        return false;
    }

    public boolean isSensorData(){
        // 没有处理4个值了
        if(instantFlow == null){
            return false;
        }
        return true;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getChannel() {
        return channel;
    }

    public void setChannel(Integer channel) {
        this.channel = channel;
    }

    public Integer getPump() {
        return pump;
    }

    public void setPump(Integer pump) {
        this.pump = pump;
    }

    public Integer getFertilizeValve() {
        return fertilizeValve;
    }

    public void setFertilizeValve(Integer fertilizeValve) {
        this.fertilizeValve = fertilizeValve;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getStirringMotor() {
        return stirringMotor;
    }

    public void setStirringMotor(Integer stirringMotor) {
        this.stirringMotor = stirringMotor;
    }

    public Float getFertilizeRatio() {
        if(fertilizeRatio == null){
            return null;
        }else {
            return fertilizeRatio/10;

        }
    }

    public void setFertilizeRatio(Float fertilizeRatio) {
        this.fertilizeRatio = fertilizeRatio;
    }

    public Integer getFault() {
        return fault;
    }

    public void setFault(Integer fault) {
        this.fault = fault;
    }

    public Float getEntryEC() {
        if(entryEC != null){
            return entryEC/10;
        }
        return entryEC;
    }

    public void setEntryEC(Float entryEC) {
        this.entryEC = entryEC;
    }

    public Float getEntryPH() {
        if(entryPH != null){
            return entryPH/10;
        }
        return entryPH;
    }

    public void setEntryPH(Float entryPH) {
        this.entryPH = entryPH;
    }

    public Float getExitEC() {
        if(exitEC != null){
            return exitEC/10;
        }
        return exitEC;
    }

    public void setExitEC(Float exitEC) {
        this.exitEC = exitEC;
    }

    public Float getExitPH() {
        if(exitPH != null){
            return exitEC/10;
        }
        return exitPH;
    }

    public void setExitPH(Float exitPH) {
        this.exitPH = exitPH;
    }

    public Float getInstantFlow() {
        if(instantFlow != null){
            return instantFlow /10;
        }
        return instantFlow;
    }

    public void setInstantFlow(Float instantFlow) {
        this.instantFlow = instantFlow;
    }

    public Double getTotalFlow() {
        if(totalFlow != null){
            return NumberUtil.double2double(totalFlow * 0.1f,2);
        }
        return totalFlow;
    }

    public void setTotalFlow(Double totalFlow) {
        this.totalFlow = totalFlow;
    }

    public Float getPressure() {
        if(pressure != null){
            return pressure *0.1f;
        }
        return pressure;
    }

    public void setPressure(Float pressure) {
        this.pressure = pressure;
    }
}
